#include <gtk/gtk.h>
#include "gtkpango.h"
#include "gtkentryaccessible.h"
+#include "gtkentryprivate.h"
#include "gtkcomboboxaccessible.h"
/* Callbacks */
gint end_pos)
{
GtkWidget *widget;
- const gchar *text;
+ gchar *text;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_text));
if (widget == NULL)
return NULL;
- /* FIXME: is this acceptable ? */
- if (!gtk_entry_get_visibility (GTK_ENTRY (widget)))
- return g_strdup ("");
-
- text = gtk_entry_get_text (GTK_ENTRY (widget));
-
- if (text)
- return g_utf8_substring (text, start_pos, end_pos > -1 ? end_pos : g_utf8_strlen (text, -1));
-
- return NULL;
+ return _gtk_entry_get_display_text (GTK_ENTRY (widget), start_pos, end_pos);
}
static gchar *
if (widget == NULL)
return NULL;
- /* FIXME: is this acceptable ? */
- if (!gtk_entry_get_visibility (GTK_ENTRY (widget)))
- return g_strdup ("");
-
return _gtk_pango_get_text_before (gtk_entry_get_layout (GTK_ENTRY (widget)),
boundary_type, offset,
start_offset, end_offset);
if (widget == NULL)
return NULL;
- /* FIXME: is this acceptable ? */
- if (!gtk_entry_get_visibility (GTK_ENTRY (widget)))
- return g_strdup ("");
-
return _gtk_pango_get_text_at (gtk_entry_get_layout (GTK_ENTRY (widget)),
boundary_type, offset,
start_offset, end_offset);
if (widget == NULL)
return NULL;
- /* FIXME: is this acceptable ? */
- if (!gtk_entry_get_visibility (GTK_ENTRY (widget)))
- return g_strdup ("");
-
return _gtk_pango_get_text_after (gtk_entry_get_layout (GTK_ENTRY (widget)),
boundary_type, offset,
start_offset, end_offset);
gtk_entry_accessible_get_character_count (AtkText *atk_text)
{
GtkWidget *widget;
- const gchar *text;
+ gchar *text;
+ glong char_count;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_text));
if (widget == NULL)
return 0;
- text = gtk_entry_get_text (GTK_ENTRY (widget));
+ text = _gtk_entry_get_display_text (GTK_ENTRY (widget), 0, -1);
+ char_count = 0;
if (text)
- return g_utf8_strlen (text, -1);
+ {
+ char_count = g_utf8_strlen (text, -1);
+ g_free (text);
+ }
- return 0;
+ return char_count;
}
static gint
GtkWidget *widget;
GtkEntry *entry;
PangoRectangle char_rect;
- const gchar *entry_text;
+ gchar *entry_text;
gint index, x_layout, y_layout;
GdkWindow *window;
gint x_window, y_window;
entry = GTK_ENTRY (widget);
gtk_entry_get_layout_offsets (entry, &x_layout, &y_layout);
- entry_text = gtk_entry_get_text (entry);
+ entry_text = _gtk_entry_get_display_text (entry, 0, -1);
index = g_utf8_offset_to_pointer (entry_text, offset) - entry_text;
+ g_free (entry_text);
+
pango_layout_index_to_pos (gtk_entry_get_layout (entry), index, &char_rect);
pango_extents_to_pixels (&char_rect, NULL);
{
GtkWidget *widget;
GtkEntry *entry;
- const gchar *text;
+ gchar *text;
gint index, x_layout, y_layout;
gint x_window, y_window;
gint x_local, y_local;
GdkWindow *window;
+ glong offset;
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_text));
if (widget == NULL)
index = -1;
}
+ offset = -1;
if (index != -1)
{
- text = gtk_entry_get_text (entry);
- return g_utf8_pointer_to_offset (text, text + index);
+ text = _gtk_entry_get_display_text (entry, 0, -1);
+ offset = g_utf8_pointer_to_offset (text, text + index);
+ g_free (text);
}
- return -1;
+ return offset;
}
static gint
gint offset)
{
GtkWidget *widget;
- const gchar *text;
+ gchar *text;
gchar *index;
+ gunichar result;
+
+ result = '\0';
widget = gtk_accessible_get_widget (GTK_ACCESSIBLE (atk_text));
if (widget == NULL)
- return '\0';
+ return result;
if (!gtk_entry_get_visibility (GTK_ENTRY (widget)))
- return '\0';
+ return result;
- text = gtk_entry_get_text (GTK_ENTRY (widget));
- if (offset >= g_utf8_strlen (text, -1))
- return '\0';
-
- index = g_utf8_offset_to_pointer (text, offset);
+ text = _gtk_entry_get_display_text (GTK_ENTRY (widget), 0, -1);
+ if (offset < g_utf8_strlen (text, -1))
+ {
+ index = g_utf8_offset_to_pointer (text, offset);
+ result = g_utf8_get_char (index);
+ g_free (text);
+ }
- return g_utf8_get_char (index);
+ return result;
}
static void
if (end < 0)
{
- const gchar *text;
+ gchar *text;
- text = gtk_entry_get_text (GTK_ENTRY (editable));
+ text = _gtk_entry_get_display_text (GTK_ENTRY (editable), 0, -1);
end = g_utf8_strlen (text, -1);
+ g_free (text);
}
if (end == start)